package control;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.gallery.GalleryService;
import model.gallery.GalleryVO;
import model.member.MemberVO;

import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class GalleryController extends MultiActionController {
	private GalleryService galleryService;

	public GalleryController(GalleryService galleryService) {
		super();
		this.galleryService = galleryService;
	}
	public ModelAndView write(HttpServletRequest request,
			HttpServletResponse response,GalleryVO vo) throws Exception{	
		HttpSession session=request.getSession();		
		MemberVO mvo=(MemberVO)session.getAttribute("mvo");
		if(mvo==null){
			return new ModelAndView("redirect:../index.jsp");
		}
		vo.setMemberVO(mvo);
		galleryService.write(vo);
		return new ModelAndView("/gallery/content","vo",vo);
	}	
	
}
